package com.ruoyi.market.http.model;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

@Data
public class ApiResponse {

    public String respCode;

    public String respMsg;

    public JSONObject data;

    public boolean isSuccess;

    public static ApiResponse success(){
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.setSuccess(true);
        apiResponse.setRespCode("200");
        apiResponse.setRespMsg("成功");
        return apiResponse;
    }

    public static ApiResponse success(JSONObject jsonObject){
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.setSuccess(true);
        apiResponse.setRespCode("200");
        apiResponse.setRespMsg("成功");
        apiResponse.setData(jsonObject);
        return apiResponse;
    }

    public static ApiResponse error(){
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.setSuccess(false);
        apiResponse.setRespCode("9999");
        apiResponse.setRespMsg("失败");
        return apiResponse;
    }

    public static ApiResponse error(String respCode, String respMsg){
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.setSuccess(false);
        apiResponse.setRespCode(respCode);
        apiResponse.setRespMsg(respMsg);
        return apiResponse;
    }

}
